﻿using System;
using System.Collections.Generic;
using Pap.Data;
using Pap.Services.WorkflowEngine;

namespace Pap.Services
{
    /// <summary>
    /// 
    /// </summary>
    public interface IWorkflowService
    {
        /// <summary>
        /// Creates new process instance from a process.
        /// </summary>
        /// <param name="Process">The process.</param>
        /// <param name="EntityID">The entity ID.</param>
        /// <param name="UserID">The user ID.</param>
        /// <param name="Notes">The notes.</param>
        void CreateProcessInstance(Process Process, Guid EntityID, Guid UserID, string Notes);

        /// <summary>
        /// Gets the process instance ID by entity.
        /// </summary>
        /// <param name="entityID">The entity ID.</param>
        /// <returns></returns>
        Guid GetProcessInstanceIDByEntity(Guid entityID);

        /// <summary>
        /// Gets the process instance by entity ID.
        /// </summary>
        /// <param name="entityID">The entity ID.</param>
        /// <returns></returns>
        IwfProcessInstance GetProcessInstanceByEntity(Guid entityID);

        /// <summary>
        /// Moves the specified process instance form its current step to another according to action.
        /// </summary>
        /// <param name="ActionState">State of the action.</param>
        /// <param name="ProcessInsnatceID">The process insnatce ID.</param>
        /// <param name="UserID">The user ID.</param>
        /// <param name="Notes">The notes.</param>
        /// <param name="completionDate">The completion date.</param>
        void Move(ActionTypes ActionState, Guid ProcessInsnatceID, Nullable<Guid> UserID, string Notes, Nullable<DateTime> completionDate);


        /// <summary>
        /// Gets the current step for the processInstance.
        /// </summary>
        /// <param name="processInsanaceID">The process insanace ID.</param>
        /// <returns></returns>
        Step GetStep(Guid processInsanaceID);

        /// <summary>
        /// Sends the processinstence back to the previous step .
        /// </summary>
        /// <param name="processInsanaceID">The process insanace ID.</param>
        void SendBack(Guid processInsanaceID);

        /// <summary>
        /// Gets all loans in certain step.
        /// </summary>
        /// <param name="Step">The step from type Steps enum</param>
        /// <returns></returns>
        IEnumerable<Guid> GetInStep(Steps Step);

        /// <summary>
        /// Gets the available actions by entity id.
        /// </summary>
        /// <param name="EntityID">The entity ID.</param>
        /// <returns></returns>
        IEnumerable<ActionTypes> GetAvailableActionsByEntityId(Guid EntityID);

        /// <summary>
        /// Gets the available actions by step id.
        /// </summary>
        /// <param name="StepId">The step id.</param>
        /// <returns></returns>
        IEnumerable<ActionTypes> GetAvailableActionsByStepId(Guid StepId);
        /// <summary>
        /// Gets the available actions by step.
        /// </summary>
        /// <param name="Step">The step.</param>
        /// <returns></returns>
        IEnumerable<ActionTypes> GetAvailableActionsByStep(Steps Step);

        /// <summary>
        /// Gets the instances in step.
        /// </summary>
        /// <param name="Step">The step.</param>
        /// <returns></returns>
        IEnumerable<IwfStepInstance> GetInstancesInStep(Steps Step);
    }
}
